package com.flute.haflute.jobbox.base.storage;

import java.util.List;
import java.util.Map;

import com.flute.haflute.jobbox.base.exception.DataNotFoundException;
import com.flute.haflute.jobbox.base.exception.ServiceUnavailableException;

public interface KeyValueStorageService {
	public String serviceType();

	public void insert(String key, String value)
			throws ServiceUnavailableException;

	public void insert(byte[] key, byte[] value)
			throws ServiceUnavailableException;

	public void batchInsert(Map<byte[], byte[]> keyvalueMap)
			throws ServiceUnavailableException;

	/**
	 * 存在返回相应的值，否则返回null
	 */
	public String get(String key) throws DataNotFoundException,
			ServiceUnavailableException;

	/**
	 * 存在返回相应的二进制值，否则返回null
	 */
	public byte[] get(byte[] key) throws DataNotFoundException,
			ServiceUnavailableException;

	/**
	 * 存在返回相应的值，否则返回null
	 * 
	 * @param begin
	 *            最小Key,包括在取值区间
	 * @param end
	 *            最大Key，包括在区间内
	 * @return 在begin和end之间的key所对应的值列表
	 * @throws ServiceUnavailableException
	 */
	public Map<String, String> batchGet(String begin, String end)
			throws ServiceUnavailableException;

	public void delete(String key) throws DataNotFoundException,
			ServiceUnavailableException;

	public void delete(byte[] key) throws DataNotFoundException,
			ServiceUnavailableException;

	public void batchDelete(List<String> keys)
			throws ServiceUnavailableException;
}
